struct Person {
    name: String,
    last_name: String,
    age: u32,
}

impl Person {
    // associated function
    // 这种方法适用于构造方法
    fn new() -> Person {
        Person {
            name: "default".to_string(),
            last_name: "default".to_string(),
            age: 0,
        }
    }

    fn from(name: String, last_name: String, age: u32) -> Person {
        Person {
            name,
            last_name,
            age,
        }
    }

    fn change_age(&mut self, new_age: u32) {
        self.age = new_age;
    }
}
fn main() {
    let mut p = Person::new();
    p.change_age(12);
    println!("{} {} {}", p.name, p.last_name, p.age);

    let p1 = Person::from("name".to_string(), "last_name".to_string(), 18);
    println!("{} {} {}", p1.name, p1.last_name, p1.age);
}
